package com.yogee.topseller.http;

import android.support.annotation.NonNull;

import com.yogee.core.base.BaseApplication;
import com.yogee.core.http.api.HttpResult;
import com.yogee.core.http.cookie.CacheInterceptor;
import com.yogee.core.http.exception.ApiException;
import com.yogee.core.http.exception.RetryWhenNetworkException;
import com.yogee.core.utils.NetUtil;
import com.yogee.core.utils.ToastUtils;
import com.yogee.topseller.BuildConfig;
import com.yogee.topseller.activity.login.model.bean.AboutUsBean;
import com.yogee.topseller.activity.login.model.bean.CheckBean;
import com.yogee.topseller.activity.login.model.bean.InterestLabelBean;
import com.yogee.topseller.activity.login.model.bean.RegisterBean;
import com.yogee.topseller.activity.login.model.bean.SendSMSBean;
import com.yogee.topseller.activity.login.model.bean.UserBean;
import com.yogee.topseller.activity.subscription.bean.ProductAppointBean;
import com.yogee.topseller.bean.AddFastQueryBean;
import com.yogee.topseller.bean.ApplyContractBean;
import com.yogee.topseller.bean.BankInformationBean;
import com.yogee.topseller.bean.BroadsideBean;
import com.yogee.topseller.bean.BzxrBean;
import com.yogee.topseller.bean.CenterInfoBean;
import com.yogee.topseller.bean.CollectBean;
import com.yogee.topseller.bean.CollectOtherCompareBean;
import com.yogee.topseller.bean.CollectOtherPkBean;
import com.yogee.topseller.bean.ConfirmCostBean;
import com.yogee.topseller.bean.ContractAddressBean;
import com.yogee.topseller.bean.DcdyBean;
import com.yogee.topseller.bean.DeleteAddressBean;
import com.yogee.topseller.bean.DeleteCardBean;
import com.yogee.topseller.bean.DingyueBean;
import com.yogee.topseller.bean.ExpressDetailBean;
import com.yogee.topseller.bean.FastQueryBean;
import com.yogee.topseller.bean.GbbdBean;
import com.yogee.topseller.bean.GbjgBean;
import com.yogee.topseller.bean.GenInfoBean;
import com.yogee.topseller.bean.GetBankInfoBean;
import com.yogee.topseller.bean.GetPlusBean;
import com.yogee.topseller.bean.GongsiProBean;
import com.yogee.topseller.bean.GpfhBean;
import com.yogee.topseller.bean.GphqBean;
import com.yogee.topseller.bean.GqczBean;
import com.yogee.topseller.bean.GrfxBean;
import com.yogee.topseller.bean.HuiyuanListModel;
import com.yogee.topseller.bean.Hymodel;
import com.yogee.topseller.bean.InterlligentFilterBean;
import com.yogee.topseller.bean.JigouBean;
import com.yogee.topseller.bean.JyycBean;
import com.yogee.topseller.bean.LogisticsInformationBean;
import com.yogee.topseller.bean.MessageInfoBean;
import com.yogee.topseller.bean.ModifyFastQueryLabelBean;
import com.yogee.topseller.bean.ModifyNameBean;
import com.yogee.topseller.bean.MyOrderListBean;
import com.yogee.topseller.bean.NewAddressBean;
import com.yogee.topseller.bean.OrderInfoBean;
import com.yogee.topseller.bean.PKBean;
import com.yogee.topseller.bean.PersonalDataBean;
import com.yogee.topseller.bean.ProductInfoBean;
import com.yogee.topseller.bean.QyfxBean;
import com.yogee.topseller.bean.RankingBean;
import com.yogee.topseller.bean.RemitCalendarBean;
import com.yogee.topseller.bean.RemoveWeChatBean;
import com.yogee.topseller.bean.ResultBean;

import com.yogee.topseller.bean.ResultBean1;
import com.yogee.topseller.bean.RetunContactBean;
import com.yogee.topseller.bean.SearchKeyBean;
import com.yogee.topseller.bean.SearchPageBean;
import com.yogee.topseller.bean.SearchResultBean;
import com.yogee.topseller.bean.SearchsBean;
import com.yogee.topseller.bean.SelectBankByCaseBean;
import com.yogee.topseller.bean.SelectCommissionBean;
import com.yogee.topseller.bean.SetBankInfoBean;
import com.yogee.topseller.bean.SetDefaultBean;
import com.yogee.topseller.bean.SetIsFirstBean;
import com.yogee.topseller.bean.ShareProductBean;
import com.yogee.topseller.bean.SmallListBean;
import com.yogee.topseller.bean.SubscribeBean;
import com.yogee.topseller.bean.SxrBean;
import com.yogee.topseller.bean.TagBean;
import com.yogee.topseller.bean.UpdateAddressBean;
import com.yogee.topseller.bean.UpdateInfoBean;
import com.yogee.topseller.bean.UpdatePhoneBean;
import com.yogee.topseller.bean.UpdatePhotoBean;
import com.yogee.topseller.bean.ViewInformationBean;
import com.yogee.topseller.bean.XwzxBean;
import com.yogee.topseller.bean.XzcfBean;
import com.yogee.topseller.bean.YzwfBean;
import com.yogee.topseller.bean.ZhoubianBean;
import com.yogee.topseller.bean.ZixunBean;
import com.yogee.topseller.bean.ZqxxBean;
import com.yogee.topseller.fragment.product.model.bean.ProductListBean;
import com.yogee.topseller.fragment.product.model.bean.ProductTypeListBean;
import com.yogee.topseller.utils.AppUtil;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.util.concurrent.TimeUnit;

import okhttp3.Cache;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Func1;
import rx.schedulers.Schedulers;

/**
 * Http服务类
 *
 * @author BiHaidong
 * @date 2016-12-5
 */
public class HttpManager {

    public volatile static HttpManager INSTANCE;

    private Service httpService;

    /**
     * 超时时间-默认60秒
     */
    public static int CONNECTION_TIME = 30;

    /**
     * 设缓存有效期为两天
     */
    private static final long CACHE_STALE_SEC = 60 * 60 * 24 * 2;

    /**
     * 查询缓存的Cache-Control设置，为if-only-cache时只查询缓存而不会请求服务器，max-stale可以配合设置缓存失效时间
     * max-stale 指示客户机可以接收超出超时期间的响应消息。如果指定max-stale消息的值，那么客户机可接收超出超时期指定值之内的响应消息。
     */
    private static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC;

    /**
     * 查询网络的Cache-Control设置，头部Cache-Control设为max-age=0
     * (假如请求了服务器并在a时刻返回响应结果，则在max-age规定的秒数内，浏览器将不会发送对应的请求到服务器，数据由缓存直接返回)时则不会使用缓存而请求服务器
     */
    private static final String CACHE_CONTROL_AGE = "max-age=0";

    /**
     * 根据网络状况获取缓存的策略
     */
    //构造方法私有
    @NonNull
    private String getCacheControl() {
        return NetUtil.isNetworkAvailable() ? CACHE_CONTROL_AGE : CACHE_CONTROL_CACHE;
    }

    private HttpManager(String baseUrl) {
        //手动创建一个OkHttpClient并设置超时时间缓存等设置
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        if (BuildConfig.LOG_DEBUG) {
            HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
            logging.setLevel(HttpLoggingInterceptor.Level.BODY);
            builder.addInterceptor(logging);
        }
        // CONNECTION_TIME
        builder.connectTimeout(CONNECTION_TIME, TimeUnit.SECONDS);
        builder.readTimeout(CONNECTION_TIME,TimeUnit.SECONDS);
        builder.writeTimeout(CONNECTION_TIME,TimeUnit.SECONDS);
        builder.addNetworkInterceptor(new CacheInterceptor());
//        /*缓存位置和大小*/
        builder.cache(new Cache(BaseApplication.app.getCacheDir(), 10 * 1024 * 1024));

        /*创建retrofit对象*/
        Retrofit retrofit = new Retrofit.Builder()
                .client(builder.build())
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .baseUrl(baseUrl)
                .build();
//
//        CacheProvider cacheProvider = new RxCache.Builder()
//                .persistence(mContext.getFilesDir(), new GsonSpeaker())
//                .using(CacheProvider.class);


        httpService = retrofit.create(Service.class);
    }

    //获取单例 无缓存
    public static HttpManager getInstance() {
        if (INSTANCE == null) {
            synchronized (HttpManager.class) {
                if (INSTANCE == null) {
                    INSTANCE = new HttpManager(Config.BASE_URL);
                }
            }
        }
        return INSTANCE;
    }

    /**
     * 用来统一处理Http的resultCode,并将HttpResult的Data部分剥离出来返回给subscriber
     *
     * @param <T> Subscriber真正需要的数据类型，也就是Data部分的数据类型
     */
    private class HttpResultFunc<T> implements Func1<HttpResult<T>, T> {
        @Override
        public T call(HttpResult<T> httpResult) {

            if (!"success".equals(httpResult.getState())) {

                throw new ApiException(httpResult.getMsg());
            }
            return httpResult.getData();
        }
    }

    /**
     * 用RXAndroid来统一处理网络请求的线程
     */
    public Observable initObservable(Observable observable) {

         /*失败后的retry配置*/
        return observable.retryWhen(new RetryWhenNetworkException())
                /*http请求线程*/
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                /*回调线程*/
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 用于配置请求参数为json
     */
    public RequestBody initRequestBody(String json) {
        JSONObject jsonObject = null;
        try {
            jsonObject = new JSONObject(json);
            jsonObject.put("version","1.3.0");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonObject.toString());
        return requestBody;
    }

//    /**
//     * 用户注册接口
//     *
//     * @param liveid      直播间id
//     */
//    public Observable gameTopList(String liveid) {
//
//        JSONObject json = new JSONObject();
//        try {
//            json.put("liveid", liveid);
//        } catch (JSONException e) {
//            e.printStackTrace();
//        }
//
//        Observable observable = httpService.gameTopList(initRequestBody(json.toString()))
//                 /*结果判断*/
//                .map(new HttpResultFunc<TopListBean>());
//
//        return initObservable(observable);
//    }

    /**
     * 上传凭证
     */
    public Observable credentials(String orderId, String userId, File file, File file1, File file2, File file3, File file4) {
        RequestBody requestData = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), orderId);
        RequestBody requestData2 = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), userId);
        // create RequestBody instance from file
        RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
        // MultipartBody.Part is used to send also the actual file name
        MultipartBody.Part body = MultipartBody.Part.createFormData("data", file.getName(), requestFile);

        RequestBody requestFile1 = RequestBody.create(MediaType.parse("multipart/form-data"), file1);
        MultipartBody.Part body1 = MultipartBody.Part.createFormData("data", file1.getName(), requestFile1);

        RequestBody requestFile2 = RequestBody.create(MediaType.parse("multipart/form-data"), file2);
        MultipartBody.Part body2 = MultipartBody.Part.createFormData("data", file2.getName(), requestFile2);

        RequestBody requestFile3 = RequestBody.create(MediaType.parse("multipart/form-data"), file3);
        MultipartBody.Part body3 = MultipartBody.Part.createFormData("data", file3.getName(), requestFile3);

        RequestBody requestFile4 = RequestBody.create(MediaType.parse("multipart/form-data"), file4);
        MultipartBody.Part body4 = MultipartBody.Part.createFormData("data", file4.getName(), requestFile4);

        Observable observable = httpService.credentials(requestData, requestData2, body, body1, body2, body3, body4)
                 /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());
        return initObservable(observable);
    }

    /**
     * 更换头像
     */
    public Observable updatePhoto(String userId, File file) {
        RequestBody requestData = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), userId);
        // create RequestBody instance from file
        RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
        // MultipartBody.Part is used to send also the actual file name
        MultipartBody.Part body = MultipartBody.Part.createFormData("data", file.getName(), requestFile);

        Observable observable = httpService.updatePhoto(requestData, body)
                 /*结果判断*/
                .map(new HttpResultFunc<UpdatePhotoBean>());
        return initObservable(observable);
    }

    /**
     * 登陆
     *
     * @param phone    账号
     * @param password 密码
     */
    public Observable userLogin(String phone, String password, String type, String cid,String code,String code_type) {

        JSONObject json = new JSONObject();
        try {
            if (type.equals(Config.LOGIN_BY_PWD)) {
                json.put("password", password);
            }
            json.put("phone", phone);
            json.put("type", type);
            json.put("uuid", "");
            json.put("token", "");
            json.put("cid", cid);
            json.put("code",code);
            json.put("code_type",code_type);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.userLogin(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<UserBean>());

        return initObservable(observable);
    }

    /**
     * 三方登陆
     *
     * @param openid id
     * @param name   姓名
     * @param img    头像
     */
    public Observable otherLogin(String openid, String name, String img, String cid) {

        JSONObject json = new JSONObject();
        try {
            json.put("openid", openid);
            json.put("name", name);
            json.put("img", img);
            json.put("cid", cid);
            json.put("uuid", "");
            json.put("token", "");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.otherLogin(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<UserBean>());

        return initObservable(observable);
    }

    /**
     * 三方登陆
     *
     * @param openid id
     * @param name   姓名
     * @param img    头像
     */
    public Observable otherLogin1(String openid,String unionid, String name, String img, String cid,String phone,String pwd) {

        JSONObject json = new JSONObject();
        try {
            json.put("openid", openid);
            json.put("unionid", unionid);
            json.put("name", name);
            json.put("img", img);
            json.put("cid", cid);
            json.put("phone",phone);
            json.put("pwd",pwd);
            json.put("uuid", "");
            json.put("token", "");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.otherLogin(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<UserBean>());

        return initObservable(observable);
    }

    /**
     * 注册电话校验
     *
     * @param phone 账号
     */
    public Observable userCheck(String phone) {

        JSONObject json = new JSONObject();
        try {
            json.put("phone", phone);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.userCheck(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<CheckBean>());

        return initObservable(observable);
    }

    /**
     * 修改手机号
     *
     * @param phone 账号
     */
    public Observable updatePhone(String userId, String phone) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("phone", phone);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.updatePhone(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<UpdatePhoneBean>());

        return initObservable(observable);
    }

    /**
     * 用户注册接口
     *
     * @param phone 账号
     */
    public Observable newUserRegistration(String phone, String pwd, String serwardCode) {

        JSONObject json = new JSONObject();
        try {
            json.put("phone", phone);
            json.put("password", pwd);
            json.put("gencode", serwardCode);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.newUserRegistration(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<RegisterBean>());

        return initObservable(observable);
    }

    /**
     * 重置密码
     *
     * @param phone    账号
     * @param passWord 密码
     */
    public Observable updatePassword(String phone, String passWord) {

        JSONObject json = new JSONObject();
        try {
            json.put("phone", phone);
            json.put("newPassword", passWord);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.forgetPassword(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<CheckBean>());
        return initObservable(observable);
    }

    /**
     * 感兴趣标签
     *
     * @return
     */
    public Observable labelList(String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.labelList(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<InterestLabelBean>());

        return initObservable(observable);
    }

    /**
     * 设置感兴趣标签
     *
     * @param labels
     * @param userId
     * @return
     */
    public Observable setlabels(String labels, String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("labels", labels);
            json.put("userId", userId);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.setlabels(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }

    /**
     * 添加收藏
     *
     * @param userId
     * @param productId
     * @return
     */
    public Observable collect(String userId, String productId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("productId", productId);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.collect(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<CollectBean>());

        return initObservable(observable);
    }


    /**
     * 首页智能筛选列表
     *
     * @param userId
     * @param total  起始数
     * @param count  条数
     * @param type   1换一批
     * @return
     */
    public Observable intelligentFilter(String userId, String total, String count, String type) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("total", total);
            json.put("count", count);
            json.put("type", type);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.intelligentFilter(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<InterlligentFilterBean>());

        return initObservable(observable);
    }

    /**
     * 产品详情
     *
     * @param productId
     * @return
     */
    public Observable productInfo(String userId, String productId, String total, String count, String isFast) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("productId", productId);
            json.put("total", total);
            json.put("count", count);
            json.put("isFast", isFast);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.productInfo(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<ProductInfoBean>());

        return initObservable(observable);
    }

    public Observable checkUserUnique(String phone) {

        JSONObject json = new JSONObject();
        try {
            json.put("phone", phone);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.checkUserUnique(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<CheckBean>());

        return initObservable(observable);
    }

    /**
     * 获取产品列表
     *
     * @param kindId
     * @param total  起始数
     * @param count  条数
     * @return
     */
    public Observable loadProductList(String userId,String kindId, int total, int count, int sort, int type) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("kindId", kindId);
            json.put("total", total + "");
            json.put("count", count + "");
            json.put("sort", sort + "");
            //如果是推荐，则不需要排序，传“”
            if (0 == sort) {
                json.put("type", "");
            } else {
                json.put("type", type + "");
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.loadProductList(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<ProductListBean>());

        return initObservable(observable);
    }

    /**
     * 获取产品列表
     *
     * @return
     */
    public Observable loadProductTypeList() {

        JSONObject json = new JSONObject();

        Observable observable = httpService.loadProductTypeList(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<ProductTypeListBean>());

        return initObservable(observable);
    }

    /**
     * 收藏列表
     *
     * @param userId
     * @param total  起始数
     * @param count  条数
     * @return
     */
    public Observable collectRecord(String userId, String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.collectRecord(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<InterlligentFilterBean>());

        return initObservable(observable);
    }

    /**
     * 认购产品列表
     *
     * @param userId
     * @param total  起始数
     * @param count  条数
     * @return
     */
    public Observable subscribe(String userId, String total, String count, String type) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("total", total);
            json.put("count", count);
            json.put("type", type);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.subscribe(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<SubscribeBean>());

        return initObservable(observable);
    }

    /**
     * 设置自动转预约 
     * @param orderId
     * @return
     */
    public Observable setAutoTurnOrder(String orderId) {

        JSONObject json = new JSONObject();
        try {
            json.put("orderId", orderId);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.setAutoTurnOrder(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }
    

    /**
     * 收藏列表
     * <p>
     * 产品预约
     *
     * @param proId
     * @param userId
     * @param name
     * @param phone
     * @param money
     * @param is
     * @return
     */
    public Observable productAppoint(String proId, String userId, String name, String phone, String money, String is, String isFast) {

        JSONObject json = new JSONObject();
        try {
            json.put("proId", proId);
            json.put("userId", userId);
            json.put("name", name);
            json.put("phone", phone);
            json.put("money", money);
            json.put("is", is);
            json.put("isFast", isFast);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.productAppoint(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ProductAppointBean>());

        return initObservable(observable);
    }

    /**
     * 产品认购
     *
     * @param proId
     * @param userId
     * @param name
     * @param phone
     * @param money
     * @param is
     * @return
     */
    public Observable productSub(String proId, String userId, String name, String phone, String money, String is, String isFast) {

        JSONObject json = new JSONObject();
        try {
            json.put("proId", proId);
            json.put("userId", userId);
            json.put("name", name);
            json.put("phone", phone);
            json.put("money", money);
            json.put("is", is);
            json.put("isFast", isFast);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.productSub(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ProductAppointBean>());

        return initObservable(observable);
    }

    /**
     * 修改个人个人信息
     *
     * @param userId
     * @param name
     * @param phone
     * @param email
     * @param clo
     * @return
     */
    public Observable updateInfo(String userId, String name, String phone, String email, String clo) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("name", name);
            json.put("phone", phone);
            json.put("email", email);
            json.put("clo", clo);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.updateInfo(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<UpdateInfoBean>());

        return initObservable(observable);
    }

    /**
     * 个人资料
     *
     * @param userId
     * @return
     */
    public Observable personalData(String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.personalData(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<PersonalDataBean>());

        return initObservable(observable);
    }

    /**
     * 个人信息
     *
     * @param userId
     * @return
     */
    public Observable viewInformation(String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.viewInformation(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ViewInformationBean>());

        return initObservable(observable);
    }

    /**
     * 收藏榜
     *
     * @param total
     * @param count
     * @return
     */
    public Observable collectBoard(String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.collectBoard(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<RankingBean>());

        return initObservable(observable);
    }

    /**
     * 热销榜
     *
     * @param total
     * @param count
     * @return
     */
    public Observable hotBoard(String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.hotBoard(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<RankingBean>());

        return initObservable(observable);
    }

    /**
     * 收益榜
     *
     * @param total
     * @param count
     * @return
     */
    public Observable receiptsBoard(String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.receiptsBoard(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<RankingBean>());

        return initObservable(observable);
    }

    /**
     * 佣金榜
     *
     * @param total
     * @param count
     * @return
     */
    public Observable commissionBoard(String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.commissionBoard(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<RankingBean>());

        return initObservable(observable);
    }

    /**
     * 提现
     *
     * @param cardId
     * @param userId
     * @return
     */
    public Observable bankCase(String cardId, String userId, String money) {

        JSONObject json = new JSONObject();
        try {
            json.put("cardId", cardId);
            json.put("userId", userId);
            json.put("money", money);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.bankCase(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());
        return initObservable(observable);
    }

    /**
     * 我的佣金
     *
     * @param type
     * @param userId
     * @param kind
     * @return
     */
    public Observable selectCommission(String type, String userId, String kind) {

        JSONObject json = new JSONObject();
        try {
            json.put("type", type);
            json.put("userId", userId);
            json.put("kind", kind);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.selectCommission(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<SelectCommissionBean>());
        return initObservable(observable);
    }

    /**
     * 添加对比
     *
     * @param proId
     * @param userId
     * @return
     */
    public Observable addCompare(String proId, String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("proId", proId);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.addCompare(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());
        return initObservable(observable);
    }

    /**
     * 新增地址
     *
     * @param userId
     * @return
     */
    public Observable newAddress(String userId, String name, String phone, String area, String address, String zipCode, String defaultAddress) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("name", name);
            json.put("phone", phone);
            json.put("area", area);
            json.put("address", address);
            json.put("zipCode", zipCode);
            json.put("defaultAddress", defaultAddress);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.newAddress(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<NewAddressBean>());

        return initObservable(observable);
    }

    /**
     * 合同地址列表
     *
     * @param userId
     * @return
     */
    public Observable contractAddress(String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.contractAddress(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<ContractAddressBean>());

        return initObservable(observable);
    }

    /**
     * 设为默认地址
     *
     * @param userId
     * @return
     */
    public Observable setDefault(String userId, String id) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("id", id);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.setDefault(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<SetDefaultBean>());

        return initObservable(observable);
    }

    /**
     * 编辑地址
     *
     * @param userId
     * @return
     */
    public Observable updateAddress(String id, String userId, String name, String phone, String area,
                                    String address, String zipCode, String defaultAddress) {

        JSONObject json = new JSONObject();
        try {
            json.put("id", id);
            json.put("userId", userId);
            json.put("name", name);
            json.put("phone", phone);
            json.put("area", area);
            json.put("address", address);
            json.put("zipCode", zipCode);
            json.put("defaultAddress", defaultAddress);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.updateAddress(initRequestBody(json.toString()))
              /*结果判断*/
                .map(new HttpResultFunc<UpdateAddressBean>());

        return initObservable(observable);
    }

    /**
     * 设为默认地址
     *
     * @param userId
     * @return
     */
    public Observable deleteAddress(String userId, String id) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("id", id);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.deleteAddress(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<DeleteAddressBean>());

        return initObservable(observable);
    }

    /**
     * 修改登录密码
     *
     * @param userId
     * @param oldPwd
     * @param newPwd
     * @return
     */
    public Observable changeLoginPwd(String userId, String oldPwd, String newPwd) {
        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("newPassword", newPwd);
            json.put("password", oldPwd);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.changeLoginPwd(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ProductAppointBean>());

        return initObservable(observable);
    }

    /**
     * 关于我们
     *
     * @return
     */
    public Observable loadAboutUs() {
        JSONObject json = new JSONObject();
        try {
            json.put("type", "0");

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.loadAboutUs(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<AboutUsBean>());

        return initObservable(observable);
    }

    /**
     * 对比产品列表
     *
     * @param userId
     * @return
     */
    public Observable loadCompareProducts(String userId) {
        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.loadCompareProducts(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ProductListBean>());

        return initObservable(observable);
    }

    /**
     * 删除对比产品
     *
     * @param userId
     * @param proId
     * @return
     */
    public Observable deleteCompareProduct(String proId, String userId) {
        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("proId", proId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.deleteCompareProduct(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<CheckBean>());

        return initObservable(observable);
    }

    /**
     * 打款日历列表
     *
     * @param date
     * @return
     */
    public Observable remitCalendarProductList(String date) {

        JSONObject json = new JSONObject();
        try {
            json.put("date", date);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.remitCalendarProductList(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<InterlligentFilterBean>());

        return initObservable(observable);
    }

    /**
     * 打款日历日历
     *
     * @param
     * @return
     */
    public Observable remitCalendar() {

        JSONObject json = new JSONObject();

        Observable observable = httpService.remitCalendar(initRequestBody(json.toString()))
              /*结果判断*/
                .map(new HttpResultFunc<RemitCalendarBean>());

        return initObservable(observable);
    }

    /**
     * 新增银行卡
     *
     * @param
     * @return
     */
    public Observable setBankInfo(String userId, String cardNumber, String bankAddress,
                                  String name, String bank, String userPhone, String isDefault) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("cardNumber", cardNumber);
            json.put("bankAddress", bankAddress);
            json.put("name", name);
            json.put("bank", bank);
            json.put("userPhone", userPhone);
            json.put("isDefault", isDefault);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.setBankInfo(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<SetBankInfoBean>());

        return initObservable(observable);
    }

    /**
     * 收款账户管理
     *
     * @param userId
     * @return
     */
    public Observable getBankInfo(String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.getBankInfo(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<GetBankInfoBean>());

        return initObservable(observable);
    }

    /**
     * 选择银行卡
     *
     * @param userId
     * @return
     */
    public Observable selectBankByCase(String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.selectBankByCase(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<SelectBankByCaseBean>());

        return initObservable(observable);
    }

    /**
     * 银行卡设为默认
     *
     * @param userId
     * @return
     */
    public Observable setIsFirst(String userId, String id) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("id", id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.setIsFirst(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<SetIsFirstBean>());

        return initObservable(observable);
    }

    /**
     * 银行卡删除
     *
     * @param id
     * @return
     */
    public Observable deleteCard(String userId, String id) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("id", id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.deleteCard(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<DeleteCardBean>());

        return initObservable(observable);
    }

    /**
     * 提现的页面
     *
     * @param cardId
     * @return
     */
    public Observable bankInformation(String userId, String cardId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("cardId", cardId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.bankInformation(initRequestBody(json.toString()))
              /*结果判断*/
                .map(new HttpResultFunc<BankInformationBean>());

        return initObservable(observable);
    }

    /**
     * pk
     *
     * @return
     */
    public Observable pkInfo(String userId, String proId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("proId", proId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.pkInfo(initRequestBody(json.toString()))
              /*结果判断*/
                .map(new HttpResultFunc<PKBean>());

        return initObservable(observable);
    }

    /**
     * 我的订单
     *
     * @return
     */
    public Observable myOrderList(String userId, String total, String count, String type) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("total", total);
            json.put("count", count);
            json.put("type", type);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.myOrderList(initRequestBody(json.toString()))
              /*结果判断*/
                .map(new HttpResultFunc<MyOrderListBean>());

        return initObservable(observable);
    }

    /**
     * 取消订单
     *
     * @return
     */
    public Observable cancelOrder(String userId, String orderId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("orderId", orderId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.cancelOrder(initRequestBody(json.toString()))
              /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }

    /**
     * 搜索页面
     *
     * @return
     */
    public Observable searchPage(String userId, String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.searchPage(initRequestBody(json.toString()))
              /*结果判断*/
                .map(new HttpResultFunc<SearchPageBean>());

        return initObservable(observable);
    }

    /**
     * 搜索标签
     *
     * @return
     */
    public Observable searchFilter() {

        Observable observable = httpService.searchFilter()
              /*结果判断*/
                .map(new HttpResultFunc<InterestLabelBean>());

        return initObservable(observable);
    }

    /**
     * 分享记录
     *
     * @param userId
     * @param total
     * @param count
     * @return
     */
    public Observable shareRecord(String userId, String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.shareRecord(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<InterlligentFilterBean>());

        return initObservable(observable);
    }

    /**
     * 浏览记录
     *
     * @param userId
     * @param total
     * @param count
     * @return
     */
    public Observable lookRecord(String userId, String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.lookRecord(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<InterlligentFilterBean>());

        return initObservable(observable);
    }

    /**
     * pk记录
     *
     * @param userId
     * @param total
     * @param count
     * @return
     */
    public Observable pkRecord(String userId, String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.pkRecord(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<CollectOtherPkBean>());

        return initObservable(observable);
    }


    /**
     * 搜索记录
     *
     * @param userId
     * @param total
     * @param count
     * @return
     */
    public Observable searchRecord(String userId, String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.searchRecord(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<SearchResultBean>());

        return initObservable(observable);
    }


    /**
     * 合同配送方式
     *
     * @return delivery
     */
    public Observable delivery(String orderId, String delivery) {

        JSONObject json = new JSONObject();
        try {
            json.put("orderId", orderId);
            json.put("delivery", delivery);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.delivery(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }

    /**
     * 订单详情
     *
     * @return delivery
     */
    public Observable orderInfo(String userId, String orderId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("orderId", orderId);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.orderInfo(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<OrderInfoBean>());

        return initObservable(observable);
    }

    /**
     * 确认费用
     *
     * @return delivery
     */
    public Observable confirmCost(String orderId) {

        JSONObject json = new JSONObject();
        try {
            json.put("orderId", orderId);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.confirmCost(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ConfirmCostBean>());

        return initObservable(observable);
    }

    /**
     * 侧边栏
     *
     * @return delivery
     */
    public Observable broadside(String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.broadside(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<BroadsideBean>());

        return initObservable(observable);
    }

    /**
     * 合同配送方式
     *
     * @return delivery
     */
    public Observable searchResult(String userId, String name, String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("name", name);
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.searchResult(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<InterlligentFilterBean>());

        return initObservable(observable);
    }

    /**
     * 合同配送方式
     *
     * @return delivery
     */
    public Observable searchResult1(String userId, String yjjs,String tzcs,String tzqx,String cplx,String fxjg,String diqu,String tzly, String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("yjjs", yjjs);
            json.put("tzcs", tzcs);
            json.put("tzqx", tzqx);
            json.put("cplx", cplx);
            json.put("fxjg", fxjg);
            json.put("diqu", diqu);
            json.put("tzly", tzly);
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.choiceIndex(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<InterlligentFilterBean>());

        return initObservable(observable);
    }

    /**
     * 合同配送方式
     *
     * @return delivery
     */
    public Observable searchResult2(String userId, String name, String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("name", name);
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.searchResult2(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<SearchsBean>());

        return initObservable(observable);
    }



    /**
     * 闪搜列表
     *
     * @return delivery
     */
    public Observable fastQuery(String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.fastQuery(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<FastQueryBean>());

        return initObservable(observable);
    }

    /**
     * 添加闪搜页面
     *
     * @param userId
     * @param type   0热门 1全部
     * @return
     */
    public Observable addFastQueryPage(String userId, String type, String queryId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("queryId", queryId);
            json.put("type", type);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.addFastQueryPage(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<AddFastQueryBean>());

        return initObservable(observable);
    }

    /**
     * 实时保存闪搜
     *
     * @param userId
     * @param labels
     * @param name
     * @param queryId
     * @return
     */
    public Observable modifyFastQueryLabel(String userId, String labels, String name, String queryId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("labels", labels);
            json.put("name", name);
            json.put("queryId", queryId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.modifyFastQueryLabel(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ModifyFastQueryLabelBean>());

        return initObservable(observable);
    }

    /**
     * 对比记录
     *
     * @param userId
     * @param total
     * @param count
     * @return
     */
    public Observable comRecord(String userId, String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.comRecord(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<CollectOtherCompareBean>());

        return initObservable(observable);
    }

    /**
     * 保存闪搜名称
     *
     * @param queryId
     * @param name
     * @return
     */
    public Observable modifyName(String queryId, String name) {

        JSONObject json = new JSONObject();
        try {
            json.put("name", name);
            json.put("queryId", queryId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.modifyName(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ModifyNameBean>());

        return initObservable(observable);
    }


    /**
     * 申请合同
     *
     * @param orderId
     * @return
     */
    public Observable applyContract(String orderId) {

        JSONObject json = new JSONObject();
        try {
            json.put("orderId", orderId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.applyContract(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ApplyContractBean>());

        return initObservable(observable);
    }

    /**
     * 秒结
     *
     * @param userId
     * @param total
     * @param count
     * @return
     */
    public Observable rapidBalance(String userId, String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.rapidBalance(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<InterlligentFilterBean>());

        return initObservable(observable);
    }

    /**
     * 一键预约
     *
     * @param orderId
     * @return
     */
    public Observable speedyAppointment(String orderId) {

        JSONObject json = new JSONObject();
        try {
            json.put("orderId", orderId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.speedyAppointment(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }

    /**
     * 添加设备CID
     *
     * @param cid
     * @return
     */
    public Observable phoneId(String cid, String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("uuid", "");
            json.put("token", "");
            json.put("cid", cid);
            json.put("userId", userId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.phoneId(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }
    
    /**
     * 搜索标签
     *
     * @param content
     * @param total
     * @param count
     * @return
     */ 
    public Observable searchLabel(String userId,String content, String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("content", content);
            json.put("total", total);
            json.put("count", count);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.searchLabel(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<TagBean>());

        return initObservable(observable);
    }

    /**
     * 闪搜
     *
     * @param userId
     * @param queryId
     * @param total
     * @param count
     * @return
     */
    public Observable beginQuery(String userId, String queryId, String total, String count) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("queryId", queryId);
            json.put("total", total);
            json.put("count", count);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.beginQuery(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<SmallListBean>());

        return initObservable(observable);
    }

    /**
     * 闪搜
     *
     * @param orderId
     * @return
     */
    public Observable getDisList(String orderId) {

        JSONObject json = new JSONObject();
        try {
            json.put("orderId", orderId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.getDisList(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<RetunContactBean>());

        return initObservable(observable);
    }


    /**
     * 获取快递公司
     *
     * @param num
     * @return
     */
    public Observable getDisNmae(String num) {

        JSONObject json = new JSONObject();
        try {
            json.put("num", num);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.getDisNmae(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<RetunContactBean>());

        return initObservable(observable);
    }

    /**
     * 获取快递公司
     *
     * @param orderId
     * @param disCom
     * @param disNum
     * @return
     */
    public Observable setOrderBackWay(String orderId, String disCom, String disNum) {

        JSONObject json = new JSONObject();
        try {
            json.put("orderId", orderId);
            json.put("disCom", disCom);
            json.put("disNum", disNum);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.setOrderBackWay(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<RetunContactBean>());

        return initObservable(observable);
    }

    /**
     * 管家信息
     *
     * @param userId
     * @return
     */
    public Observable genInfo(String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.genInfo(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<GenInfoBean>());

        return initObservable(observable);
    }

    /**
     * 清理历史记录
     *
     * @param userId
     * @return
     */
    public Observable clearHistory(String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.clearHistory(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }

    /**
     * 管家页面物流信息
     *
     * @param userId
     * @return
     */
    public Observable genCenterInfo(String userId, String type) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("type", type);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.genCenterInfo(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<CenterInfoBean>());

        return initObservable(observable);
    }

    /**
     * 解除微信绑定
     *
     * @param userId
     * @return
     */
    public Observable removeWechat(String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.removeWechat(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<RemoveWeChatBean>());

        return initObservable(observable);
    }

    /**
     * 解除微信绑定
     *
     * @param userId
     * @return
     */
    public Observable changeWechat(String openId,String unionid,String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("openId", openId);
            json.put("unionid", unionid);
            json.put("userId", userId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.changeWechat(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<RemoveWeChatBean>());

        return initObservable(observable);
    }



    /**
     * 订单详情物流信息
     *
     * @param orderId
     * @return
     */
    public Observable logisticsInformation(String orderId) {

        JSONObject json = new JSONObject();
        try {
            json.put("orderId", orderId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.logisticsInformation(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<LogisticsInformationBean>());

        return initObservable(observable);
    }

    /**
     * 选择产品准备对比
     *
     * @param userId
     * @param proId
     * @return
     */
    public Observable setChooseProId(String userId, String proId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("proId", proId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.setChooseProId(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }

    /**
     * 系统通知详情
     *
     * @param type
     * @param userId
     * @return
     */
    public Observable genMessageInfo(String type, String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("type", type);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.genMessageInfo(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<MessageInfoBean>());

        return initObservable(observable);
    }

    /**
     * 查看物流
     *
     * @param userId
     * @return
     */
    public Observable readOrderDis(String orderId, String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("orderId", orderId);
            json.put("userId", userId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.readOrderDis(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ExpressDetailBean>());

        return initObservable(observable);
    }

    /**
     * 获取地理位置
     *
     * @param location
     * @param userId
     * @param coordinates
     * @return
     */
    public Observable getLocation(String location, String userId, String coordinates) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("location", location);
            json.put("coordinates", coordinates);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.getLocation(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }

    /**
     * 推送的产品列表
     *
     * @param count
     * @param total
     * @param proId
     * @return
     */
    public Observable getProductList(String count, String total, String proId) {

        JSONObject json = new JSONObject();
        try {
            json.put("count", count);
            json.put("total", total);
            json.put("proId", proId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.getProductList(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<InterlligentFilterBean>());

        return initObservable(observable);
    }

    /**
     * 分享产品
     *
     * @param userId
     * @param proId
     * @return
     */
    public Observable shareProduct(String userId, String proId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("proId", proId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.shareProduct(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ShareProductBean>());

        return initObservable(observable);
    }

    /**
     * 获得推送状态
     *
     * @param userId
     * @return
     */
    public Observable getPlus(String userId,String cid) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("cid", cid);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.getPlus(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<GetPlusBean>());

        return initObservable(observable);
    }

    /**
     * 设置推送
     * 
     * @param userId
     * @param
     * @return
     */
    public Observable setPlus(String cid,String userId,String isPlus) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("cid", cid);
            json.put("isPlus", isPlus);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.setPlus(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }

    /**
     * 搜索关键词
     * @param
     * @return
     */
    public Observable defaultShow() {

        JSONObject json = new JSONObject();
        Observable observable = httpService.defaultShow(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<SearchKeyBean>());

        return initObservable(observable);
    }


    /**
     * 发送验证码
     *
     * @param phone    账号
     * @param type 验证码登录或者是注册，找回密码
     */
    public Observable sendSMS(String phone,String type) {

        JSONObject json = new JSONObject();
        try {
            json.put("phone", phone);
            json.put("type", type);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.sendSMS(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<SendSMSBean>());
        return initObservable(observable);
    }

    /**
     * 验证验证码
     * @param code
     * @param code_type
     * @return
     */
    public Observable registSendSMS(String phone,String code ,String code_type){
        JSONObject json = new JSONObject();
        try {
            json.put("phone", phone);
            json.put("code", code);
            json.put("code_type", code_type);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.registSendSMS(initRequestBody(json.toString()))
                 /*结果判断*/
                .map(new HttpResultFunc<SendSMSBean>());
        return initObservable(observable);
    }


    /**
     * 首页其他列表数据
     *
     * @param userId
     * @param total
     * @param count
     * @param type:0 其他 1信托  2资管 3债券
     * @return
     */
    public Observable productLable(String userId, String total, String count,String type) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("total", total);
            json.put("count", count);
            json.put("type", type);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.productLable(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<InterlligentFilterBean>());

        return initObservable(observable);
    }


    /**
     * 删除闪搜分组
     * @param queryId
     * @param labels
     * @return
     */
    public Observable deleteFastQuery(String queryId, String labels) {

        JSONObject json = new JSONObject();
        try {
            json.put("labels", labels);
            json.put("queryId", queryId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.deleteFastQuery(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ModifyFastQueryLabelBean>());

        return initObservable(observable);
    }

    /**
     * 判断用户是否有闪搜
     * @param userId
     * @return
     */
    public Observable modifyFastQueryLabelIsNull(String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.modifyFastQueryLabelIsNull(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }

    /**
     * 微信授权登录时判断用户是否已经绑定手机号
     * @param openid
     * @return
     */
    public Observable otherLoginopenId(String openid) {

        JSONObject json = new JSONObject();
        try {
            json.put("unionid", openid);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.otherLoginopenId(initRequestBody(json.toString()))
                /*结果判断*/
                .map(new HttpResultFunc<UserBean>());

        return initObservable(observable);
    }


    /**
     * 查询银行卡信息
     *
     * @return
     */
    public Observable getBankInfoKa(String cardId) {

        JSONObject json = new JSONObject();
        try {
            json.put("Id", cardId);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.getBankInfoKa(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<GetBankInfoBean.BankListBean>());

        return initObservable(observable);
    }

    /**
     * 为您推荐
     * @param userId
     * @return
     */
    public Observable redisinfo(String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.redisinfo(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<InterlligentFilterBean>());
        return initObservable(observable);
    }

    /**
     * 修改银行卡
     *
     * @param
     * @return
     */
    public Observable updateBankInfoka(String userId, String cardId,String cardNumber, String bankAddress,
                                  String name, String bank, String userPhone, String isDefault) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("Id", cardId);
            json.put("cardNumber", cardNumber);
            json.put("bankAddress", bankAddress);
            json.put("name", name);
            json.put("bank", bank);
            json.put("userPhone", userPhone);
            json.put("isDefault", isDefault);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.updateBankInfoka(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }


    /**
     * 支付宝支付
     *
     * @param
     * @return
     */
    public Observable alipay(String userId,String id) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("id", id);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.alipay(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }


    /**
     * 获取充值列表
     * @return
     */
    public Observable gethuiyuanList(String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.gethuiyuanList(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<HuiyuanListModel>());
        return initObservable(observable);
    }



    /**
     * 微信支付
     *
     * @param
     * @return
     */
    public Observable wxPay(String userId,String id) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("id", id);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.wxPay(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<String>());

        return initObservable(observable);
    }


    /**
     * 获取会员信息
     * @param userId
     * @return
     */
    public Observable viewInformationDay(String userId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.viewInformationDay(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<Hymodel>());

        return initObservable(observable);
    }

    /**
     * 获取会员信息
     * @param userId
     * @return
     */
    public Observable rebate(String userId,String productId) {

        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("productId", productId);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        Observable observable = httpService.rebate(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<ZixunBean>());

        return initObservable(observable);
    }

    public Observable rebateLogs(String userId,String productId,String centerId) {
        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("productId", productId);
            json.put("centerId", centerId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.rebateLogs(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }

    public Observable rebatePay(String userId) {
        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.rebatePay(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }

    /**
     * 产品机构
     * @param productId
     * @param type
     * @return
     */
    public Observable relatedCompanyTypeDetails(String productId,String type) {
        JSONObject json = new JSONObject();
        try {
            json.put("productId", productId);
            json.put("type", type);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.relatedCompanyTypeDetails(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<JigouBean>());

        return initObservable(observable);
    }

    /**
     * 机构分类产品查询
     * @param relatedCompanyId
     * @return
     */
    public Observable relatedCompanyTypeProductList(String relatedCompanyId,String total,String count) {
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("total", total);
            json.put("count", count);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.relatedCompanyTypeProductList(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<GongsiProBean>());

        return initObservable(observable);
    }

    /**
     * 天眼查--新闻列表
     * @param relatedCompanyId
     * @param type
     */
    public Observable eyeCheckXw(String relatedCompanyId, String type,String userId,String cmpanyType,String companyproId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("type", type);
            json.put("userId", userId);
            json.put("cmpanyType", cmpanyType);
            json.put("companyproId", companyproId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckXw(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<XwzxBean>());

        return initObservable(observable);
    }

    /**
     * 行政处罚
     * @param relatedCompanyId
     * @param type
     * @return
     */
    public Observable eyeCheckXZCF(String relatedCompanyId, String type,String userId,String cmpanyType,String companyproId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("type", type);
            json.put("userId", userId);
            json.put("cmpanyType", cmpanyType);
            json.put("companyproId", companyproId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckXZCF(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<XzcfBean>());

        return initObservable(observable);
    }

    /**
     * 个人风险
     * @param relatedCompanyId
     * @param type
     * @return
     */
    public Observable eyeCheckGrfx(String relatedCompanyId, String type,String userId,String cmpanyType,String companyproId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("type", type);
            json.put("userId", userId);
            json.put("cmpanyType", cmpanyType);
            json.put("companyproId", companyproId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckGRFX(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<GrfxBean>());

        return initObservable(observable);
    }

    /**
     * 被执行人
     * @param relatedCompanyId
     * @param type
     * @return
     */
    public Observable eyeCheckBzxr(String relatedCompanyId, String type,String userId,String cmpanyType,String companyproId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("type", type);
            json.put("userId", userId);
            json.put("cmpanyType", cmpanyType);
            json.put("companyproId", companyproId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckBZXR(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<BzxrBean>());

        return initObservable(observable);
    }

    /**
     * 股票行情
     * @param relatedCompanyId
     * @param type
     * @return
     */
    public Observable eyeCheckGPHQ(String relatedCompanyId, String type,String userId,String cmpanyType,String companyproId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("type", type);
            json.put("userId", userId);
            json.put("cmpanyType", cmpanyType);
            json.put("companyproId", companyproId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckGPHQ(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<GphqBean>());

        return initObservable(observable);
    }

    /**
     * 股本结构
     * @param relatedCompanyId
     * @param type
     * @return
     */
    public Observable eyeCheckGBJG(String relatedCompanyId, String type,String userId,String cmpanyType,String companyproId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("type", type);
            json.put("userId", userId);
            json.put("cmpanyType", cmpanyType);
            json.put("companyproId", companyproId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckGBJG(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<GbjgBean>());

        return initObservable(observable);
    }

    /**
     * 股票分红
     * @param relatedCompanyId
     * @param type
     * @return
     */
    public Observable eyeCheckGPFH(String relatedCompanyId, String type,String userId,String cmpanyType,String companyproId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("type", type);
            json.put("userId", userId);
            json.put("cmpanyType", cmpanyType);
            json.put("companyproId", companyproId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckGPFH(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<GpfhBean>());

        return initObservable(observable);
    }

    /**
     * 股本变动
     * @param relatedCompanyId
     * @param type
     * @return
     */
    public Observable eyeCheckGBBD(String relatedCompanyId, String type,String userId,String cmpanyType,String companyproId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("type", type);
            json.put("userId", userId);
            json.put("cmpanyType", cmpanyType);
            json.put("companyproId", companyproId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckGBBD(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<GbbdBean>());

        return initObservable(observable);
    }

    /**
     * 失信人
     * @param relatedCompanyId
     * @param type
     * @return
     */
    public Observable eyeCheckSXR(String relatedCompanyId, String type,String userId,String cmpanyType,String companyproId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("type", type);
            json.put("userId", userId);
            json.put("cmpanyType", cmpanyType);
            json.put("companyproId", companyproId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckSXR(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<SxrBean>());

        return initObservable(observable);
    }

    /**
     * 严重违法
     * @param relatedCompanyId
     * @param type
     * @return
     */
    public Observable eyeCheckYzwf(String relatedCompanyId, String type,String userId,String cmpanyType,String companyproId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("type", type);
            json.put("userId", userId);
            json.put("cmpanyType", cmpanyType);
            json.put("companyproId", companyproId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckYZWF(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<YzwfBean>());

        return initObservable(observable);
    }
    /**
     * 债券信息
     * @param relatedCompanyId
     * @param type
     * @return
     */
    public Observable eyeCheckZqxx(String relatedCompanyId, String type,String userId,String cmpanyType,String companyproId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("type", type);
            json.put("userId", userId);
            json.put("cmpanyType", cmpanyType);
            json.put("companyproId", companyproId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckZQXX(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<ZqxxBean>());

        return initObservable(observable);
    }

    /**
     * 债券信息
     * @param relatedCompanyId
     * @param type
     * @return
     */
    public Observable eyeCheckGqcz(String relatedCompanyId, String type,String userId,String cmpanyType,String companyproId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("type", type);
            json.put("userId", userId);
            json.put("cmpanyType", cmpanyType);
            json.put("companyproId", companyproId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckGQCZ(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<GqczBean>());

        return initObservable(observable);
    }
    /**
     * 企业风险
     * @param relatedCompanyId
     * @param type
     * @return
     */
    public Observable eyeCheckQyfx(String relatedCompanyId, String type,String userId,String cmpanyType,String companyproId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("type", type);
            json.put("userId", userId);
            json.put("cmpanyType", cmpanyType);
            json.put("companyproId", companyproId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckQYFX(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<QyfxBean>());

        return initObservable(observable);
    }
    /**
     * 经营异常
     * @param relatedCompanyId
     * @param type
     * @return
     */
    public Observable eyeCheckJyyc(String relatedCompanyId, String type,String userId,String cmpanyType,String companyproId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("type", type);
            json.put("userId", userId);
            json.put("cmpanyType", cmpanyType);
            json.put("companyproId", companyproId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckJYYC(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<JyycBean>());

        return initObservable(observable);
    }

    /**
     * 动产抵押
     * @param relatedCompanyId
     * @param type
     * @return
     */
    public Observable eyeCheckDcdy(String relatedCompanyId, String type,String userId,String cmpanyType,String companyproId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("type", type);
            json.put("userId", userId);
            json.put("cmpanyType", cmpanyType);
            json.put("companyproId", companyproId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckDCDY(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<DcdyBean>());

        return initObservable(observable);
    }


    /**
     * 当前会员状态
     * @param userId
     * @return
     */
    public Observable userOrderTypeInfo(String userId){
        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.userOrderTypeInfo(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<ResultBean1>());

        return initObservable(observable);
    }


    /**
     * 订阅
     * @param userId
     * @return
     */
    public Observable usersubscribe(String userId,String proId){
        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("proId", proId);
            json.put("type", "2");

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.usersubscribe(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<ResultBean1>());

        return initObservable(observable);
    }

    /**
     * 订阅列表
     * @param userId
     * @return
     */
    public Observable usersubscribeList(String userId){
        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.userSubscribeList(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<DingyueBean>());

        return initObservable(observable);
    }

    /**
     * 订阅删除
     * @param id
     * @return
     */
    public Observable userSubscribeDelete(String id){
        JSONObject json = new JSONObject();
        try {
            json.put("Id", id);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.userSubscribeDelete(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<ResultBean1>());

        return initObservable(observable);
    }

    /**
     * 订阅取消
     * @param id
     * @return
     */
    public Observable userSubscribeSubscribe(String id){
        JSONObject json = new JSONObject();
        try {
            json.put("Id", id);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.userSubscribeSubscribe(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<ResultBean1>());

        return initObservable(observable);
    }

    /**
     * 订阅取消
     * @return
     */
    public Observable eyeCheckCount(String relatedCompanyId,String userId){
        JSONObject json = new JSONObject();
        try {
            json.put("relatedCompanyId", relatedCompanyId);
            json.put("userId", userId);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.eyeCheckCount(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<ZhoubianBean>());

        return initObservable(observable);
    }

    public Observable islogOut(){
        JSONObject json = new JSONObject();

        Observable observable = httpService.islogOut(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }

    public Observable userFeedBack(String userId,String proName,String describe,String phone){
        JSONObject json = new JSONObject();
        try {
            json.put("userId", userId);
            json.put("proName", proName);
            json.put("describe", describe);
            json.put("phone", phone);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        Observable observable = httpService.userFeedBack(initRequestBody(json.toString()))
               /*结果判断*/
                .map(new HttpResultFunc<ResultBean>());

        return initObservable(observable);
    }


}